Core.Test.registerTest({
	group: "dao",
	name: "Core.Storage.ValueResolver",
	envs: ["storage.simple"],
	
	_should: {
		error: {
			"Should error on trying to get primitive with tail": "Can't retrieve subpath 'length' from primitive.",			
			"Should error on trying to get function with tail": "Can't retrieve subpath 'prop' from primitive.",
			"Should error on getting using path without leading dots": "Path 'user.login.name' does not have any leading dots."
		}
	},
	
	before: function() {
		this.conf = new Core.Storage.Configuration();
		this.valuer = new Core.Storage.ValueResolver(this, this.conf, null);
	},
	
	override: function(property, value) {
		this.conf.override(property, value, this, 20);
	},
	
	"Should get using global path": function() {
		Assert.equal("Bilbo", this.valuer.get("..user.login.name"));
	},
	
	"Should get undefined using unexisting global path": function() {
		Assert.equal(undefined, this.valuer.get("..user21.login.name"));
	},
	
	"Should get primitive using local path": function() {
		this.override("prop", 10);
		Assert.equal(10, this.valuer.get(".prop"));
	},
	
	"Should get objet using local path": function() {
		this.override("prop", {prop: "value"});
		Assert.equal({prop: "value"}, this.valuer.get(".prop"));
	},
	
	"Should get array using local path": function() {
		this.override("prop", ["a", "aa", "aaa"]);
		Assert.equal(["a", "aa", "aaa"], this.valuer.get(".prop"));
	},
	
	"Should get function using local path": function() {
		var fn = function() {};
		
		this.override("prop", fn);
		Assert.equal(fn, this.valuer.get(".prop"));
	},
	
	"Should get & evaluate function if forced, using local path": function() {
		var fn = function() { return 213; };

		this.override("prop", fn);
		Assert.equal(213, this.valuer.get(".prop", null, true));
	},
	
	"Should get undefined using unexisting local path": function() {
		Assert.equal(undefined, this.valuer.get(".prop", null, true));
	},
	
	"Should get object's property using local path with tail": function() {
		this.override("prop", {prop: "value"});
		Assert.equal("value", this.valuer.get(".prop.prop"));
	},
	
	"Should get arrays's property using local path with tail": function() {
		this.override("prop", ["a", "aa", "aaa"]);
		Assert.equal("aa", this.valuer.get(".prop.1"));
	},
	
	"Should error on trying to get primitive with tail": function() {
		this.override("prop", "value");
		this.valuer.get(".prop.length");
	},
	
	"Should error on trying to get function with tail": function() {
		var fn = function() { return {prop: "value"}; };
		
		this.override("prop", fn);
		this.valuer.get(".prop.prop", null, true);
	},
	
	"Should error on getting using path without leading dots": function() {
		this.valuer.get("user.login.name");
	}
});